﻿using AutoMapper;
using Comm100.Application.Services;
using Comm100.Framework.Auditing;
using Comm100.Framework.Authorization;
using Comm100.Public.Audit;
using Bot.Application.Dto;
using Bot.Application.Services;
using Bot.Domain.Bo;
using Bot.Domain.Entities;
using Bot.Domain.Interfaces;
using System;
using System.Collections.Generic;
using System.Text;
using Bot.Domain;

namespace Bot.Application.IntentQuestionSelectedKeywords.Service
{
    public class IntentQuestionSelectedKeywordAppService : BaseAppService, IIntentQuestionSelectedKeywordAppService
    {
        private IIntentQuestionSelectedKeywordDomainService _domainService;

        public IntentQuestionSelectedKeywordAppService(IIntentQuestionSelectedKeywordDomainService domainService) : base()
        {
            this._domainService = domainService;
        }

        [Authorization(BotPermission.MANAGE_BOTS)]
        //[Audit(BotEntity.INTENTQUESTIONSELECTEDKEYWORD, AuditAction.DESTROY)]
        public void Delete(Guid id)
        {
            _domainService.Delete(id);
        }

        [Authorization(BotPermission.MANAGE_BOTS)]
        //[Audit(BotEntity.INTENTQUESTIONSELECTEDKEYWORD, AuditAction.CREATE)]
        public IntentQuestionSelectedKeywordDto Add(IntentQuestionSelectedKeywordCreateDto dto)
        {
            IntentQuestionSelectedKeyword intentQuestionSelectedKeyword = _domainService.Create(Mapper.Map<IntentQuestionSelectedKeyword>(dto));
            return Mapper.Map<IntentQuestionSelectedKeywordDto>(intentQuestionSelectedKeyword);
        }

        [Authorization(BotPermission.MANAGE_BOTS)]
        //[Audit(BotEntity.INTENTQUESTIONSELECTEDKEYWORD, AuditAction.UPDATE)]
        public IntentQuestionSelectedKeywordDto Update(IntentQuestionSelectedKeywordUpdateDto dto)
        {
            IntentQuestionSelectedKeyword intentQuestionSelectedKeyword = _domainService.Update(Mapper.Map<IntentQuestionSelectedKeywordUpdateBo>(dto));
            return Mapper.Map<IntentQuestionSelectedKeywordDto>(intentQuestionSelectedKeyword);
        }

        public IntentQuestionSelectedKeywordDto Get(Guid id)
        {
            IntentQuestionSelectedKeyword intentQuestionSelectedKeyword = _domainService.Get(id);
            return Mapper.Map<IntentQuestionSelectedKeywordDto>(intentQuestionSelectedKeyword);
        }

        public IEnumerable<IntentQuestionSelectedKeywordDto> GetList()
        {
            IEnumerable<IntentQuestionSelectedKeyword> list = _domainService.List();
            return Mapper.Map<IEnumerable<IntentQuestionSelectedKeywordDto>>(list);
        }
    }
}
